package com.yunchao.maintenance.data

import androidx.room.Room
import com.yunchao.maintenance.data.datasource.MaintenanceDatabase
import com.yunchao.maintenance.data.repository.MaintenanceInfoRepositoryImpl
import com.yunchao.maintenance.domain.repository.MaintenanceInfoRepository
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import org.koin.android.ext.koin.androidContext
import org.koin.dsl.module

val dataModule = module {

    // 提供数据库实例
    single {
        Room.databaseBuilder(
            androidContext(),
            MaintenanceDatabase::class.java,
            "maintenance_database"
        ).build()
    }

    // 提供 DAO 实例
    single { get<MaintenanceDatabase>().maintenanceInfoDao() }


    // 提供 MaintenanceInfoRepository 实例
    single<MaintenanceInfoRepository> {
        MaintenanceInfoRepositoryImpl(
            androidContext(),
            get(),
            get()
        )
    }
}